Skip to content

feat(ui): dark/light mode toggle with system preference detection#523

Merged
Tinna23 merged 1 commit into
StellarCommons:mainfrom
demilade18-git:feat/513-dark-light-mode-toggle
Jun 21, 2026
Merged

feat(ui): dark/light mode toggle with system preference detection#523
Tinna23 merged 1 commit into
StellarCommons:mainfrom
demilade18-git:feat/513-dark-light-mode-toggle

Conversation

@demilade18-git

Copy link
Copy Markdown
Contributor

Closes #513

Summary

Adds a full theme system to Stellar Explain, converting all hardcoded colors to CSS custom properties and adding a toggle button that persists across page reloads.

Changes

New files:

  • src/hooks/useTheme.ts — reads localStorage, falls back to prefers-color-scheme, syncs data-theme attribute
  • src/components/ThemeToggle.tsx — sun/moon icon button with CSS var styling

Modified files:

  • src/app/globals.css — full dark (default) + light token set as CSS custom properties
  • src/app/layout.tsx — inline FOUC-prevention script on <html>
  • src/components/AppShell.tsx — CSS vars throughout + ThemeToggle in header
  • src/components/Card.tsx, Pill.tsx, Label.tsx, AddressChip.tsx — all CSS vars
  • src/components/SearchBar.tsx, TabSwitcher.tsx — all CSS vars
  • src/components/TransactionResult.tsx, AccountResult.tsx — all CSS vars
  • src/components/landing/Navbar.tsx, HeroSection.tsx, src/app/page.tsx — CSS vars + ThemeToggle in Navbar

Bug fixes (pre-existing):

  • Fixed 3 TypeScript errors in UseCasesSection.tsx (entry and d possibly undefined)
  • Added missing eslint-config-prettier dependency (build was broken on main)

Acceptance Criteria

  • Dark mode looks identical to current app (no visual regression)
  • Light mode is fully usable and aesthetically consistent
  • Toggle button visible in AppShell header and landing Navbar on all pages
  • Theme persists across page reloads (localStorage)
  • System preference respected when no explicit choice has been made
  • No flash of wrong theme on initial page load (inline script in <head>)
  • All components use CSS variables — no hardcoded color values remain
  • Theme transitions are smooth (transition: background-color 0.2s ease on html)
  • Landing page also respects theme
  • TypeScript compiles with no errors (npm run build passes)

…StellarCommons#513)

- Add CSS custom properties for dark (default) and light themes in globals.css
- Create useTheme hook: reads localStorage, falls back to prefers-color-scheme
- Create ThemeToggle component (sun/moon icon button) for AppShell and Navbar
- Add FOUC-prevention inline script to layout.tsx
- Convert all hardcoded colors to CSS vars in: AppShell, Card, Pill, Label,
  AddressChip, SearchBar, TabSwitcher, TransactionResult, AccountResult
- Update landing page (Navbar, HeroSection, page.tsx) to use CSS vars
- Fix 3 pre-existing TS errors in UseCasesSection.tsx
- Add missing eslint-config-prettier dependency
@Tinna23 Tinna23 merged commit 77e0241 into StellarCommons:main Jun 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI — Add dark/light mode toggle with system preference detection

2 participants